package com.woniuxy.company5.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.company5.dto.RepDistributionDto;
import com.woniuxy.company5.service.RepDistributionService;
import com.woniuxy.company5.util.Result;
import com.woniuxy.company5.vo.RepDistributionVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/repDistribution")
public class RepDistributionController {
    @Resource
    private RepDistributionService repDistributionService;
    @PostMapping("query")
    public Result queryByLike(@RequestBody RepDistributionDto repDistributionDto){
        PageHelper.startPage(repDistributionDto.getCurrentPage(),repDistributionDto.getPageSize(),true);
        List<RepDistributionVo> repDistributionVo = repDistributionService.selectByLike(repDistributionDto);
        PageInfo<RepDistributionVo> pageInfo = new PageInfo<>(repDistributionVo);
        return Result.ok().data("userList",repDistributionVo).data("total",pageInfo.getTotal());
    }
}
